package Text21;
import java.util.*;
public class Main {
    public static int N = N = 12010;
    public static int[]f=new int[N];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        ArrayList<good> goods = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int v=scanner.nextInt();
            int w=scanner.nextInt();
            int s=scanner.nextInt();
            for (int k = 1; k <=s ; k*=2) {
                s-=k;
                goods.add(new good(k*v,k*w));
            }
            if(s>0){
                goods.add(new good(s*v,s*w));
            }
        }
        for (good g: goods) {
            for (int i = m; i>=g.v ; i--) {
                f[i]=Math.max(f[i],f[i-g.v]+g.w);
            }
        }
        System.out.println(f[m]);
    }
}

class good{
    int v;
    int w;
    public good(int v, int w) {
        this.v = v;
        this.w = w;
    }
}